Skip to content

Conversation

@Jiaqi-Lv
Copy link
Collaborator

@Jiaqi-Lv Jiaqi-Lv commented Oct 25, 2025

🚀Summary

This PR introduces a new GrandQC Tissue Detection Model for digital pathology quality control and integrates EfficientNet-based encoder architecture into the TIAToolbox framework.


✨Key Changes

  • New Model Architecture
    • Added grandqc.py implementing a UNet++ decoder with EfficientNet encoder for tissue segmentation.
    • Includes preprocessing (JPEG compression + ImageNet normalization), postprocessing (argmin-based mask generation), and batch inference utilities.
  • EfficientNet Encoder
    • Added timm_efficientnet.py providing configurable EfficientNet encoders with dilation support and custom input channels.
  • Pretrained Model Config
    • Updated pretrained_model.yaml to register grandqc_tissue_detection_mpp10 with associated IO configuration.
    • Corrected IOSegmentorConfig references and adjusted resolutions for SCCNN models.
  • Testing
    • Added comprehensive unit tests for:
      • GrandQCModel functionality, preprocessing/postprocessing, and decoder blocks.
      • EfficientNet encoder utilities and scaling logic.

Impact

  • Enables high-resolution tissue detection for WSI quality control using state-of-the-art architectures.
  • Improves flexibility for segmentation tasks with EfficientNet encoders.
  • Enhances code quality and consistency through updated linting and formatting tools.

Tasks

  • Re-host GrandQC model weights on TIA Hugging Face
  • Update pretrained_model.yaml
  • Update requirements.txt
  • Define GrandQC model architecture
  • Add example usage
  • Remove segmentation-models-pytorch dependency
  • Wait for response from GrandQC authors
  • Add tests
  • Tidy up

@Jiaqi-Lv Jiaqi-Lv self-assigned this Oct 25, 2025
@Jiaqi-Lv Jiaqi-Lv added the enhancement New feature or request label Oct 25, 2025
@codecov
Copy link

codecov bot commented Oct 25, 2025

Codecov Report

❌ Patch coverage is 96.31148% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.76%. Comparing base (c535eab) to head (9c62b72).

Files with missing lines Patch % Lines
...iatoolbox/models/architecture/timm_efficientnet.py 92.74% 3 Missing and 6 partials ⚠️
Additional details and impacted files
@@                    Coverage Diff                     @@
##           dev-define-engines-abc     #965      +/-   ##
==========================================================
+ Coverage                   94.72%   94.76%   +0.04%     
==========================================================
  Files                          73       75       +2     
  Lines                        9234     9478     +244     
  Branches                     1208     1238      +30     
==========================================================
+ Hits                         8747     8982     +235     
- Misses                        452      455       +3     
- Partials                       35       41       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Jiaqi-Lv Jiaqi-Lv requested a review from Copilot October 25, 2025 20:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR integrates the GrandQC tissue detection model into TIAToolBox, adding a UNet++ based tissue segmentation capability trained at 10 microns per pixel resolution. The implementation leverages the segmentation-models-pytorch library to avoid reimplementing the UNet++ architecture.

  • Adds GrandQC tissue detection model architecture and pretrained weights
  • Integrates model with existing tissue masking functionality
  • Adds comprehensive test coverage and example usage

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tiatoolbox/models/architecture/grandqc.py Defines the TissueDetectionModel class with UNet++ architecture and custom preprocessing/postprocessing
tiatoolbox/data/pretrained_model.yaml Adds GrandQC model configuration and fixes IOConfig class references across multiple models
tests/models/test_arch_grandqc.py Implements unit tests for model creation, weight loading, and inference
requirements/requirements.txt Adds segmentation-models-pytorch dependency
tiatoolbox/wsicore/wsireader.py Integrates GrandQC masker into tissue_mask method with 10mpp resolution handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Jiaqi-Lv Jiaqi-Lv requested a review from Copilot October 25, 2025 20:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Jiaqi-Lv Jiaqi-Lv requested a review from Copilot October 31, 2025 10:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Jiaqi-Lv Jiaqi-Lv marked this pull request as draft October 31, 2025 12:26
@shaneahmed
Copy link
Member

GrandQC authors have confirmed that we are allowed to integrate the model in TIAToolbox. Please add appropriate licensing and citation information.

@shaneahmed shaneahmed changed the title 🆕 Add GrandQC tissue detection model 🆕 Add GrandQC Tissue Segmentation Model Nov 17, 2025
@Jiaqi-Lv Jiaqi-Lv requested a review from Copilot November 21, 2025 18:08
@Jiaqi-Lv Jiaqi-Lv marked this pull request as ready for review November 21, 2025 18:09
Copilot finished reviewing on behalf of Jiaqi-Lv November 21, 2025 18:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 10 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@shaneahmed shaneahmed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Jiaqi-Lv
I have updated docstrings in this commit.
1895e38

Can you check these?

super().__init__(conv1, conv2)


class UnetPlusPlusDecoder(nn.Module):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure why this is part of grandqc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants